from django.conf.urls.defaults import *

from cmsdj import settings, categories
from cmsdj.feeds import LatestContentFeed
from cmsdj.sitemap import SitemapContenidos, SitemapCategorias
from django.contrib import admin
from django.views.generic.simple import direct_to_template
import cmsdj
from cmsdj.cfg.models import SiteCfg
admin.autodiscover()

template_name = SiteCfg.current_cfg().template

mapas = {'contenidos' : SitemapContenidos,
         'categorias' : SitemapCategorias,
         }
    
urlpatterns = patterns('',
    (r'^$', 'core.views.index'),
    
    (r'^category/list/$','categories.views.list'),
    (r'^category/(?P<slug>[\w-]+)/$','categories.views.details'),
    
    (r'^content/(?P<slug>[\w-]+)/$','content.views.details'),
    (r'^content/(?P<slug>[\w-]+)/toprint/$','content.views.details_to_print'),
    (r'^content/page/(?P<page>\d+)/$', 'core.views.index'),
    
    (r'^comments/', include('django.contrib.comments.urls')),
    
    (r'^admin/', include(admin.site.urls)),
    
    (r'^cv$', direct_to_template, {'template': 'curr/carlos-martin-sanchez.cv.html', 'mimetype':'text/html'}),
    (r'^robots.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype':'text/plain'}),
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
    (r'^templates/prettify/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.TEMPLATE_DIR + 'prettify/'}),
    (r'^templates/' + template_name +'/fonts/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.TEMPLATE_DIR + template_name + '/fonts/'}),
    (r'^templates/' + template_name +'/css/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.TEMPLATE_DIR + template_name + '/css/'}),
    (r'^templates/' + template_name +'/img/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.TEMPLATE_DIR + template_name + '/img/'}),
    (r'^templates/curr/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.TEMPLATE_DIR + 'curr/'}),
    
    (r'^feeds/content/last/$', LatestContentFeed()),
    (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': mapas}),

)
